<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // includes()  返回数组中是否包含参数这个元素 
        var arr = ["a","b","c"];
        var n = arr.includes("a");
        console.log(n);  // true

        var str = "b";
        if(str === arr[0] || str === arr[1] || str === arr[2]){
            console.log(true); // true
        }else{
            console.log(false);
        }

        var isshow = false;
        for(var i = 0; i < arr.length;i++){
            if(str === arr[i]){
                isshow = true
            }
        }
        console.log(isshow);  // true
        // arr = ["a","b","c"]; str = "b";
        function includes2(array,string){
            for(var i = 0; i < array.length;i++){
                // console.log(array.length);
                // console.log(i); 0  1 ,arr[1]时，return true
                if(string === array[i]){   
                    return true;
                }
            }
                return false;
        }
        // 
        console.log(includes2(arr,str));   // true

        // 
        Array.prototype.includes3 = function(string){
            for(var i = 0; i < this.length;i++){
                if(string === this[i]){
                    return true
                }
            }
            return false;
        }
        console.log(arr.includes3("b"));  // true
 
    </script>
</body>
</html>